package org.example.controller;

import de.felixroske.jfxsupport.FXMLController;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import org.example.dao.SettingsRepository;
import org.example.model.Settings;
import org.example.model.SettingsEntity;
import org.springframework.beans.factory.annotation.Autowired;

import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;

/**
 * @Author: wwy
 * @Date: 2020/11/26 10:57
 */

@FXMLController
public class MainStageController implements Initializable {
    @Autowired
    private SettingsRepository settingsRepository;
    private SettingsDialogViewController settingsDialogViewController = new SettingsDialogViewController();
    @Override
    public void initialize(URL location, ResourceBundle resources) {

    }

    /**
     * 打开设置弹出框
     */
    @FXML
    private void handleSetting(){
        List<SettingsEntity> settingsRepositoryAll = settingsRepository.findAll();
        if(settingsRepositoryAll != null && settingsRepositoryAll.size()>0){
            settingsDialogViewController.showSettingsDialog(settingsRepositoryAll.get(0));
        }else{
            settingsDialogViewController.showSettingsDialog(null);
        }

    }
}
